package com.sgb.kjwl.view.widget.pick;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.RelativeLayout;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;

import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.LayoutPickExpertDetailViewBinding;
import com.sgb.kjwl.view.ui.adapter.pick.PickExpertDetailQualificationViewAdapter;
import com.sgb.zhaocai.entity.PickExpertDetailEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * 专家库详情页-执业资格证书
 */
public class PickExpertDetailQualificationView extends RelativeLayout {
    private Context mContext;
    private LayoutPickExpertDetailViewBinding binding;
    private PickExpertDetailQualificationViewAdapter adapter;
    private List<PickExpertDetailEntity.Qualifications> qualificationsList = new ArrayList<>();

    public PickExpertDetailQualificationView(Context context) {
        super(context);
        this.mContext = context;
        initView();
    }

    public PickExpertDetailQualificationView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        this.mContext = context;
        initView();
    }

    public PickExpertDetailQualificationView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext = context;
        initView();
    }

    private void initView() {
        binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.layout_pick_expert_detail_view, this, true);
        if (adapter == null) {
            adapter = new PickExpertDetailQualificationViewAdapter(mContext, qualificationsList);
        }
        binding.pickTitle.setText("执业资格证书");
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
        binding.pickRecycler.setLayoutManager(layoutManager);
        binding.pickRecycler.setAdapter(adapter);
        binding.pickRecycler.setLoadingMoreEnabled(false);
        binding.pickRecycler.setPullRefreshEnabled(false);
    }

    public void showInfoView(List<PickExpertDetailEntity.Qualifications> qualificationsList) {
        if (adapter == null) return;
        adapter.setDatas(qualificationsList);
    }

}
